/**
 * Created by wm123 on 2017/7/14.
 */
const { Role } = require('board-game');

class TankRole extends Role {
    constructor(server, room, player, team, index) {
        super(server, room, player, team, index);
    }
    directionStart(direction) {
        this.game.directionStart(this, direction);
    }
    directionEnd(direction) {
        this.game.directionEnd(this, direction);
    }
    relive(player) {
        this.game.relive(this, player);
    }
    over(win, game) {
        let result = super.over(win, game);
        result.scores = game.battle.tanks.map(tank => ({ role: tank.role.player.name, score: tank.score.value })).sort((a, b) => a.score - b.score);
        return result;
    }
    shot() {
        this.game.shot(this);
    }
}

module.exports = TankRole;
